home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / sonson.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  10KB  |  334 lines

  1. /***************************************************************************
  2.  
  3. Son Son memory map (preliminary)
  4.  
  5. driver by Mirko Buffoni
  6.  
  7.  
  8. MAIN CPU:
  9.  
  10. 0000-0fff RAM
  11. 1000-13ff Video RAM
  12. 1400-17ff Color RAM
  13. 2020-207f Sprites
  14. 4000-ffff ROM
  15.  
  16. read:
  17. 3002      IN0
  18. 3003      IN1
  19. 3004      IN2
  20. 3005      DSW0
  21. 3006      DSW1
  22.  
  23. write:
  24. 3000      horizontal scroll
  25. 3008      ? one of these two should be
  26. 3018      ? the watchdog reset
  27. 3010      command for the audio CPU
  28. 3019      trigger FIRQ on audio CPU
  29.  
  30.  
  31. SOUND CPU:
  32. 0000-07ff RAM
  33. e000-ffff ROM
  34.  
  35. read:
  36. a000      command from the main CPU
  37.  
  38. write:
  39. 2000      8910 #1 control
  40. 2001      8910 #1 write
  41. 4000      8910 #2 control
  42. 4001      8910 #2 write
  43.  
  44. ***************************************************************************/
  45.  
  46. #include "driver.h"
  47. #include "vidhrdw/generic.h"
  48. #include "cpu/m6809/m6809.h"
  49.  
  50.  
  51.  
  52. extern unsigned char *sonson_scrollx;
  53.  
  54. void sonson_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  55. void sonson_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  56.  
  57.  
  58.  
  59. WRITE_HANDLER( sonson_sh_irqtrigger_w )
  60. {
  61.     static int last;
  62.  
  63.  
  64.     if (last == 0 && data == 1)
  65.     {
  66.         /* setting bit 0 low then high triggers IRQ on the sound CPU */
  67.         cpu_cause_interrupt(1,M6809_INT_FIRQ);
  68.     }
  69.  
  70.     last = data;
  71. }
  72.  
  73.  
  74.  
  75. static struct MemoryReadAddress readmem[] =
  76. {
  77.     { 0x0000, 0x17ff, MRA_RAM },
  78.     { 0x4000, 0xffff, MRA_ROM },
  79.     { 0x3002, 0x3002, input_port_0_r },    /* IN0 */
  80.     { 0x3003, 0x3003, input_port_1_r },    /* IN1 */
  81.     { 0x3004, 0x3004, input_port_2_r },    /* IN2 */
  82.     { 0x3005, 0x3005, input_port_3_r },    /* DSW0 */
  83.     { 0x3006, 0x3006, input_port_4_r },    /* DSW1 */
  84.     { -1 }    /* end of table */
  85. };
  86.  
  87. static struct MemoryWriteAddress writemem[] =
  88. {
  89.     { 0x0000, 0x0fff, MWA_RAM },
  90.     { 0x1000, 0x13ff, videoram_w, &videoram, &videoram_size },
  91.     { 0x1400, 0x17ff, colorram_w, &colorram },
  92.     { 0x2020, 0x207f, MWA_RAM, &spriteram, &spriteram_size },
  93.     { 0x3000, 0x3000, MWA_RAM, &sonson_scrollx },
  94. { 0x3008, 0x3008, MWA_NOP },
  95.     { 0x3010, 0x3010, soundlatch_w },
  96. { 0x3018, 0x3018, MWA_NOP },
  97.     { 0x3019, 0x3019, sonson_sh_irqtrigger_w },
  98.     { 0x4000, 0xffff, MWA_ROM },
  99.     { -1 }    /* end of table */
  100. };
  101.  
  102. static struct MemoryReadAddress sound_readmem[] =
  103. {
  104.     { 0x0000, 0x07ff, MRA_RAM },
  105.     { 0xa000, 0xa000, soundlatch_r },
  106.     { 0xe000, 0xffff, MRA_ROM },
  107.     { -1 }  /* end of table */
  108. };
  109.  
  110. static struct MemoryWriteAddress sound_writemem[] =
  111. {
  112.     { 0x0000, 0x07ff, MWA_RAM },
  113.     { 0x2000, 0x2000, AY8910_control_port_0_w },
  114.     { 0x2001, 0x2001, AY8910_write_port_0_w },
  115.     { 0x4000, 0x4000, AY8910_control_port_1_w },
  116.     { 0x4001, 0x4001, AY8910_write_port_1_w },
  117.     { 0xe000, 0xffff, MWA_ROM },
  118.     { -1 }  /* end of table */
  119. };
  120.  
  121.  
  122.  
  123. INPUT_PORTS_START( sonson )
  124.     PORT_START    /* IN0 */
  125.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
  126.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  127.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  128.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  129.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  130.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  131.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  132.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  133.  
  134.     PORT_START    /* IN1 */
  135.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  136.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  137.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
  138.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  139.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
  140.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
  141.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  142.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  143.  
  144.     PORT_START    /* IN2 */
  145.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  146.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  147.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  148.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  149.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
  150.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
  151.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  152.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
  153.  
  154.     PORT_START    /* DSW0 */
  155.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coinage ) )
  156.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  157.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  158.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  159.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  160.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  161.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  162.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  163.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  164.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  165.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  166.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  167.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  168.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  169.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  170.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  171.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  172.     PORT_DIPNAME( 0x10, 0x10, "Coinage affects" )
  173.     PORT_DIPSETTING(    0x10, DEF_STR( Coin_A ) )
  174.     PORT_DIPSETTING(    0x00, DEF_STR( Coin_B ) )
  175.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
  176.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  177.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  178.     PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
  179.     PORT_DIPNAME( 0x80, 0x80, "unknown" )    /* maybe flip screen */
  180.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  181.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  182.  
  183.     PORT_START    /* DSW1 */
  184.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
  185.     PORT_DIPSETTING(    0x03, "3" )
  186.     PORT_DIPSETTING(    0x02, "4" )
  187.     PORT_DIPSETTING(    0x01, "5" )
  188.     PORT_DIPSETTING(    0x00, "7" )
  189.     PORT_DIPNAME( 0x04, 0x00, "2 Players Game" )
  190.     PORT_DIPSETTING(    0x04, "1 Credit" )
  191.     PORT_DIPSETTING(    0x00, "2 Credits" )
  192.     PORT_DIPNAME( 0x18, 0x08, DEF_STR( Bonus_Life ) )
  193.     PORT_DIPSETTING(    0x08, "20000 80000 100000" )
  194.     PORT_DIPSETTING(    0x00, "30000 90000 120000" )
  195.     PORT_DIPSETTING(    0x18, "20000" )
  196.     PORT_DIPSETTING(    0x10, "30000" )
  197.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
  198.     PORT_DIPSETTING(    0x60, "Easy" )
  199.     PORT_DIPSETTING(    0x40, "Medium" )
  200.     PORT_DIPSETTING(    0x20, "Hard" )
  201.     PORT_DIPSETTING(    0x00, "Hardest" )
  202.     PORT_DIPNAME( 0x80, 0x80, "Freeze" )
  203.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  204.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  205. INPUT_PORTS_END
  206.  
  207.  
  208.  
  209. static struct GfxLayout charlayout =
  210. {
  211.     8,8,    /* 8*8 characters */
  212.     1024,    /* 1024 characters */
  213.     2,    /* 2 bits per pixel */
  214.     { 1024*8*8, 0 },    /* the two bitplanes are separated */
  215.     { 0, 1, 2, 3, 4, 5, 6, 7 },    /* pretty straightforward layout */
  216.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  217.     8*8    /* every char takes 8 consecutive bytes */
  218. };
  219. static struct GfxLayout spritelayout =
  220. {
  221.     16,16,    /* 16*16 sprites */
  222.     512,    /* 512 sprites */
  223.     3,    /* 3 bits per pixel */
  224.     { 2*2048*8*8, 2048*8*8, 0 },    /* the two bitplanes are separated */
  225.         { 8*16+7, 8*16+6, 8*16+5, 8*16+4, 8*16+3, 8*16+2, 8*16+1, 8*16+0,    /* pretty straightforward layout */
  226.        7, 6, 5, 4, 3, 2, 1, 0 },
  227.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  228.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  229.     32*8    /* every sprite takes 32 consecutive bytes */
  230. };
  231.  
  232.  
  233. static struct GfxDecodeInfo gfxdecodeinfo[] =
  234. {
  235.     { REGION_GFX1, 0, &charlayout,      0, 64 },
  236.     { REGION_GFX2, 0, &spritelayout, 64*4, 32 },
  237.     { -1 } /* end of array */
  238. };
  239.  
  240.  
  241.  
  242. static struct AY8910interface ay8910_interface =
  243. {
  244.     2,    /* 2 chips */
  245.     1500000,    /* 1.5 MHz ? */
  246.     { 30, 30 },
  247.     { 0 },
  248.     { 0 },
  249.     { 0 },
  250.     { 0 }
  251. };
  252.  
  253.  
  254.  
  255. static struct MachineDriver machine_driver_sonson =
  256. {
  257.     /* basic machine hardware */
  258.     {
  259.         {
  260.             CPU_M6809,
  261.             2000000,    /* 2 Mhz (?) */
  262.             readmem,writemem,0,0,
  263.             interrupt,1
  264.         },
  265.         {
  266.             CPU_M6809 | CPU_AUDIO_CPU,
  267.             2000000,    /* 2 Mhz (?) */
  268.             sound_readmem,sound_writemem,0,0,
  269.             interrupt,4    /* FIRQs are triggered by the main CPU */
  270.         },
  271.     },
  272.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  273.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  274.     0,
  275.  
  276.     /* video hardware */
  277.     32*8, 32*8, { 1*8, 31*8-1, 1*8, 31*8-1 },
  278.     gfxdecodeinfo,
  279.     32,64*4+32*8,
  280.     sonson_vh_convert_color_prom,
  281.  
  282.     VIDEO_TYPE_RASTER,
  283.     0,
  284.     generic_vh_start,
  285.     generic_vh_stop,
  286.     sonson_vh_screenrefresh,
  287.  
  288.     /* sound hardware */
  289.     0,0,0,0,
  290.     {
  291.         {
  292.             SOUND_AY8910,
  293.             &ay8910_interface
  294.         }
  295.     }
  296. };
  297.  
  298.  
  299.  
  300. /***************************************************************************
  301.  
  302.   Game driver(s)
  303.  
  304. ***************************************************************************/
  305.  
  306. ROM_START( sonson )
  307.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code + 3*16k for the banked ROMs images */
  308.     ROM_LOAD( "ss.01e",       0x4000, 0x4000, 0xcd40cc54 )
  309.     ROM_LOAD( "ss.02e",       0x8000, 0x4000, 0xc3476527 )
  310.     ROM_LOAD( "ss.03e",       0xc000, 0x4000, 0x1fd0e729 )
  311.  
  312.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the audio CPU */
  313.     ROM_LOAD( "ss3.v12",      0xe000, 0x2000, 0x1135c48a )
  314.  
  315.     ROM_REGION( 0x04000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  316.     ROM_LOAD( "ss5.v12",      0x00000, 0x2000, 0x990890b1 )    /* characters */
  317.     ROM_LOAD( "ss6.v12",      0x02000, 0x2000, 0x9388ff82 )
  318.  
  319.     ROM_REGION( 0x0c000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  320.     ROM_LOAD( "ss7.v12",      0x00000, 0x4000, 0x32b14b8e )    /* sprites */
  321.     ROM_LOAD( "ss8.v12",      0x04000, 0x4000, 0x9f59014e )
  322.     ROM_LOAD( "ss9.v12",      0x08000, 0x4000, 0xe240345a )
  323.  
  324.     ROM_REGION( 0x0240, REGION_PROMS )
  325.     ROM_LOAD( "ss12.bin",     0x0000, 0x0020, 0xc8eaf234 )    /* red/green component */
  326.     ROM_LOAD( "ss13.bin",     0x0020, 0x0020, 0x0e434add )    /* blue component */
  327.     ROM_LOAD( "ssb2.bin",     0x0040, 0x0100, 0x6ce8ac39 )    /* character lookup table */
  328.     ROM_LOAD( "ssb.bin",      0x0140, 0x0100, 0xd4f7bfb5 )    /* sprite lookup table */
  329. ROM_END
  330.  
  331.  
  332.  
  333. GAME( 1984, sonson, 0, sonson, sonson, 0, ROT0, "Capcom", "Son Son" )
  334.